export default function setFn(vm){

  setOn(vm.vnode,vm);
}
function setOn (vnode,vm){
  if(vnode.tag ==undefined)return
  if(vnode.props.on){
    var on = vnode.props.on
    for(let key in on){
      if(key ==='click'){
        var fn = vm.$options.methods[on[key]]
        vnode.elm.addEventListener(key,()=>{
          fn.call(vm)
        })
      }else if(key ==='input'){
        var fn = on[key]
        vnode.elm.addEventListener(key,($event)=>{
          vnode.elm.setAttribute('value',$event.target.value)
          fn.call(vm,$event)
        })
      }
      
    }
  }
  if(vnode.children.length>0){
    for (let index = 0; index < vnode.children.length; index++) {
      setOn(vnode.children[index],vm)
    }
  }
}